/*!--------------------------------------------------------------------------
 @file simat.h
 @date 11/16/2010

 SIMat is the basic data structure of matrix.

*/
/*

 Copyright (c) 2010, XInfo
 All rights reserved.

 Redistribution and use in source and binary forms, with or without
 modification, are permitted provided that the following conditions are met:

    * Redistributions of source code must retain the above copyright notice,
    this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above copyright
    notice, this list of conditions and the following disclaimer in the
    documentation and/or other materials provided with the distribution.
    * Neither the name of the XInfo nor the names of its contributors may be
    used to endorse or promote products derived from this software without
    specific prior written permission.

 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------*/

#ifndef SI_MAT_H
#define SI_MAT_H

C_BEGIN_DECLS

/*! Matrix declaration */
typedef struct _SIMat SIMat;


/*! Create matrix.

 @return X Error
*/
int
simat_create(int rows,                          /*!< Number of rows */
             int columns,                       /*!< Number of columns */
             int type,                          /*!< Data type */
             SIMat** mat                        /*!< Matrix created */ 
             );

/*! Create matrix by copy.

 @return X Error
*/
int
simat_create_by_copy(SIMat* copyMat,            /*!< Matrix copy */
                     SIMat** mat                /*!< Matrix created */
                     );

/*! Destroy matrix.

 @return None
*/
void
simat_destroy(SIMat* mat                        /*!< Matrix instance */
              );

/*! Get data of matrix.

 @return X Error
 */
int
simat_get_data(SIMat* mat,                      /*!< Matrix instance */
               void** data                      /*!< Data */
               );

/*! Get row mumber of matrix.

 @return X Error
*/
int
simat_get_rows(SIMat* mat,                      /*!< Matrix instance */
               int* rows                        /*!< Number of rows */
               );

/*! Get column mumber of matrix.

 @return X Error
*/
int
simat_get_columns(SIMat* mat,                   /*!< Matrix instance */
                  int* columns                  /*!< Number of columns */
                  );

/*! Get type of matrix.

 @return X Error
*/
int
simat_get_type(SIMat* mat,                      /*!< Matrix instance */
               int* type                        /*!< Type */
               );

/*! Get depth of matrix.

 @return X Error
*/
int
simat_get_depth(SIMat* mat,                     /*!< Matrix instance */
                int* depth                      /*!< Depth value (SI_8U ~ SI_64F) */
                );

/*! Get channel number of matrix.

 @return X Error
*/
int
simat_get_channels(SIMat* mat,                  /*!< Matrix instance */
                   int* channels                /*!< Number of channels */
                   );

/*! Get size of matrix.

 Size is pixel number. Equal to m_rows * m_columns.

 @return X Error
*/
int
simat_get_size(SIMat* mat,                      /*!< Matrix instance */
               int* size                        /*!< Size */
               );

/*! Is matrix empty.

 Empty matrix means data (m_data) is NULL or size (m_rows * m_columns) is 0.

 @return Is empty
 */
int
simat_is_empty(SIMat* mat                       /*!< Matrix instance */
               );

/*! Is matrix same type with another matrix.

 Same type matrices means m_rows, m_columns and m_flags all are equivalent.

 @return Is same type
 */
int
simat_is_same_type(SIMat* mat,                  /*!< Matrix instance */
                   SIMat* rhs                   /*!< Another matrix instance */
                   );

/*! Clear matrix.

 @return None
*/
void
simat_clear(SIMat* mat                          /*!< Matrix instance */
            );

/*! Reset matrix.

 @return X Error
*/
int
simat_reset(SIMat* mat,                         /*!< Matrix instance */
            int rows,                           /*!< Number of rows */
            int columns,                        /*!< Number of columns */
            int type                            /*!< Data type */
            );

/*! Copy source to destination matrix.

 @return X Error
*/
int
simat_copy(SIMat* dst,                          /*!< Destination matrix */
           SIMat* src                           /*!< Source matrix */
           );

C_END_DECLS

#endif  // SI_MAT_H

